﻿<local:ChoBaseWindowEx x:Class="ChoWorkflowDashboard.AddOrEditTaskWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:ChoWorkflowDashboard"
        xmlns:cinchoo="clr-namespace:Cinchoo.Core;assembly=Cinchoo.Core"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:tk="http://schemas.microsoft.com/wpf/2008/toolkit"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
        Title="Task Editor" Height="797" Width="786" ResizeMode="NoResize" ShowInTaskbar="False" 
        Topmost="False" Loaded="ChoBaseWindow_Loaded"
        BorderBrush="{DynamicResource AccentColorBrush}"
        BorderThickness="1"
        ShowMaxRestoreButton="false" ShowMinButton="false"
                     >
    <Window.Resources>
        <cinchoo:ChoIntegerToBoolConverter x:Key="IntegerToBoolConverter" />
        <cinchoo:ChoBoolInverterConverter x:Key="BoolInverterConverter" />
        <cinchoo:ChoNullableDbNullConverter x:Key="NullableDbNullConverter" />
        <local:MonthSelectedConverter x:Key="monthSelectedConverter" />
        <local:DateConverter x:Key="dateConverter" />
        <local:ObjectValueToBoolConverter x:Key="objectValueToBoolConverter" />
        <local:DependencyBackgroudColorConverter x:Key="dependencyBackgroudColorConverter" />
        <local:DependencyExistsConverter x:Key="dependencyExistsConverter" />
        <CollectionViewSource x:Key="checkedMonths" Source="{Binding Path=YearMonths}" Filter="IsCheckedFilter" />
        <CollectionViewSource Source="{Binding Path=Machines}" x:Key="sortedMachines">
            <CollectionViewSource.SortDescriptions>
                <scm:SortDescription />
            </CollectionViewSource.SortDescriptions>
        </CollectionViewSource>
    </Window.Resources>
    <Grid x:Name="MasterGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="30" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right"  >
            <Button Content="OK" Margin="2" Height="23" HorizontalAlignment="Left" Name="btnOK" VerticalAlignment="Top" Width="75" TabIndex="50" Click="btnOK_Click" IsDefault="True" Tag="4" />
            <Button Content="Cancel" Margin="2" Height="23" HorizontalAlignment="Left" Name="btnCancel" VerticalAlignment="Top" Width="75" TabIndex="51" Click="btnCancel_Click" IsCancel="True" Tag="5" />
        </StackPanel>
        <GroupBox Grid.Row="0" Header="Task Info" Margin="2" HorizontalAlignment="Stretch" Name="groupBox1" VerticalAlignment="Top">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="26" />
                    <RowDefinition Height="3"/>
                    <RowDefinition Height="26" />
                    <RowDefinition Height="3"/>
                    <RowDefinition Height="26" />
                    <RowDefinition Height="3"/>
                    <RowDefinition Height="26" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="15*" />
                    <ColumnDefinition Width="35*" />
                    <ColumnDefinition Width="15*" />
                    <ColumnDefinition Width="35*" />
                </Grid.ColumnDefinitions>

                <Label Grid.Row="0" Grid.Column="0" Content="Task Name:" Name="label1" Width="75" HorizontalAlignment="Left" />
                <xctk:WatermarkTextBox Grid.Row="0" Grid.Column="1" Name="txtTaskName" TabIndex="1" 
                             Text="{Binding Path=TaskGroupCategoryInfo.Name, UpdateSourceTrigger=PropertyChanged}" Tag="1" 
                             CharacterCasing="Upper" MaxLength="50" ToolTip="Accepts only [A-Za-z0-9] characters" 
                             HorizontalAlignment="Stretch" local:Masking.Mask="^[A-Za-z0-9_]*$" TextWrapping="NoWrap" />

                <Label Grid.Row="0" Grid.Column="2" Content="Machine:" Name="label12" Width="61" HorizontalAlignment="Left" />
                <Grid Grid.Row="0" Grid.Column="3" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <ComboBox Grid.Row="0" Grid.Column="0" Name="cmbMachineName" 
                                          SelectedItem="{Binding TaskGroupCategoryInfo.MachineName}" TabIndex="2" 
                                          ItemsSource="{Binding Source={StaticResource sortedMachines}}"
                                  IsSynchronizedWithCurrentItem="True" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" >
                    </ComboBox>
                    <Button Grid.Row="0" Grid.Column="1" Margin="5,0,0,0" Width="50" Name="btnChooseCluster" Click="btnChooseCluster_Click">Choose</Button>
                </Grid>
                <Label Grid.Row="2" Grid.Column="0" Content="WF Name:" Name="label2" Width="75" HorizontalAlignment="Left" />
                <ComboBox Grid.Row="2" Grid.Column="1" Name="cmbWorkflowName" 
                          SelectedItem="{Binding TaskGroupCategoryInfo.WorkflowName}" TabIndex="2" ItemsSource="{Binding Path=WFNames}" 
                              IsSynchronizedWithCurrentItem="True" 
                              HorizontalAlignment="Stretch" SelectionChanged="cmbWorkflowName_SelectionChanged"/>

                <Label Grid.Row="2" Grid.Column="2" Content="Cmd Params:" Name="label23" HorizontalAlignment="Left" />

                <Label Grid.Row="4" Grid.Column="0" Content="Comments:" Name="label231" Width="75" HorizontalAlignment="Left" />
                <Grid Grid.Row="2" Grid.Column="3" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBox Name="txtCmdParams" TabIndex="4" Tag="2" Text="{Binding Path=TaskGroupCategoryInfo.CmdParameters, UpdateSourceTrigger=PropertyChanged}" MouseDoubleClick="txtCmdParams_MouseDoubleClick" 
                         ToolTip="Double click to open editor..." />
                    <Button Grid.Row="0" Grid.Column="1" Width="50" Margin="5,0,0,0" Name="btnEditCmdParams" Click="btnEditCmdParams_Click">Edit</Button>
                </Grid>
                
                <TextBox Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="3" Name="txtComments" TabIndex="4" Tag="2" Text="{Binding Path=TaskGroupCategoryInfo.Description, UpdateSourceTrigger=PropertyChanged}" MouseDoubleClick="txtComments_MouseDoubleClick"
                         ToolTip="Double click to edit..." />

                <Label Content="No of Retry:" Grid.Row="6" Grid.Column="0" Name="label8" Width="75" HorizontalAlignment="Left" />
                <Grid Grid.Row="6" Grid.Column="1" Grid.ColumnSpan="3">
                    <StackPanel Orientation="Horizontal" >
                        <xctk:IntegerUpDown Name="iudNoOfRetry" AllowTextInput="False" Minimum="0" Maximum="5" Text="{Binding Path=TaskGroupCategoryInfo.MaxNoOfRetry, UpdateSourceTrigger=PropertyChanged}" TabIndex="5" Width="100" />
                        <Label Content="Retry Sleep (sec):" Name="label9" Width="100" />
                        <xctk:IntegerUpDown Name="iudSleep" Width="100" AllowTextInput="False" Minimum="0" Maximum="360" Text="{Binding Path=TaskGroupCategoryInfo.SleepBetweenRetry, UpdateSourceTrigger=PropertyChanged}" TabIndex="6" />
                        <Label Content="Timeout (sec):" Name="label10" Width="100" />
                        <xctk:IntegerUpDown Name="iudTimeout"  Width="100" Minimum="0" Increment="1" Text="{Binding Path=TaskGroupCategoryInfo.Timeout, UpdateSourceTrigger=PropertyChanged}" TabIndex="7" />
                    </StackPanel>
                </Grid>
            </Grid>
        </GroupBox>
        <StackPanel Grid.Row="1" Name="grpTaskSchedule">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="30*" />
                    <ColumnDefinition Width="70*" />
                </Grid.ColumnDefinitions>

                <GroupBox Grid.Row="0" Grid.Column="0" Margin="2" Header="Schedules" Name="groupBox3"
                              VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                    <DockPanel LastChildFill="True">
                        <DockPanel DockPanel.Dock="Top">
                            <Button Content="Add New" DockPanel.Dock="Right" Name="btnNewSchedule" Width="75" Margin="2" Click="btnNewSchedule_Click"  TabIndex="12" HorizontalAlignment="Right" />
                            <xctk:WatermarkTextBox Name="txtScheduleName" DockPanel.Dock="Left" HorizontalAlignment="Stretch" Margin="2" CharacterCasing="Upper"  TabIndex="11" 
                                     MaxLength="50" ToolTip="Accepts only [A-Za-z0-9] characters" local:Masking.Mask="^[A-Za-z0-9_]*$"  />
                        </DockPanel>
                        <DockPanel DockPanel.Dock="Bottom">
                            <CheckBox DockPanel.Dock="Left" Content="Enabled" Margin="2" Name="chkEnabled"  IsChecked="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.ENABLED}" TabIndex="9" HorizontalAlignment="Left" VerticalAlignment="Center" />
                            <Button DockPanel.Dock="Right" Content="Delete" Margin="2" Name="btnDeleteSchedule" Width="75" Click="btnDeleteSchedule_Click"  TabIndex="10" HorizontalAlignment="Right" />
                        </DockPanel>
                        <ListBox Name="lstSchedules" Margin="2"  ItemsSource="{Binding Path=TaskSchedulesTable}" 
                                     SelectionChanged="lstSchedules_SelectionChanged" IsSynchronizedWithCurrentItem="True" TabIndex="8"
                                     HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding SCHEDULE_NAME}" >
                                        <TextBlock.ToolTip>
                                            <ToolTip Content="{Binding AUDIT_INFO}" Background="Aqua" Foreground="Black" />
                                        </TextBlock.ToolTip>
                                    </TextBlock>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </DockPanel>
                </GroupBox>
                <GroupBox Grid.Row="0" Grid.Column="1" Margin="2"  Header="Schedule Parameters" Name="grpScheduleDetails"
                              VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="0">
                            <Label Content="StartDate:" Name="label4" HorizontalAlignment="Left" HorizontalContentAlignment="Left" />
                            <DatePicker Name="dpStartDate" Margin="2" TabIndex="15" SelectedDateChanged="dpStartDate_SelectedDateChanged" HorizontalAlignment="Stretch" DisplayDateStart="{x:Static sys:DateTime.Now}" >
                                <DatePicker.SelectedDate>
                                    <Binding ElementName="lstSchedules" Path="SelectedItem.Row.START_DATE" Converter="{StaticResource dateConverter}" NotifyOnTargetUpdated="True" NotifyOnSourceUpdated="True" UpdateSourceTrigger ="PropertyChanged"/>
                                </DatePicker.SelectedDate>
                                <DatePicker.Resources>
                                    <Style TargetType="DatePickerTextBox">
                                        <Setter Property="IsReadOnly" Value="True"/>
                                    </Style>
                                </DatePicker.Resources>
                            </DatePicker>
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" >
                            <Label Content="EndDate:" Name="label5" HorizontalAlignment="Stretch" />
                            <DockPanel HorizontalAlignment="Stretch" >
                                <Button Content="Reset" DockPanel.Dock="Right" Margin="2" HorizontalAlignment="Right" Name="btnEndDateReset" VerticalAlignment="Top" Width="50" Click="btnEndDateReset_Click" />
                                <DatePicker Name="dpEndDate" Margin="2" TabIndex="16" SelectedDateChanged="dpEndDate_SelectedDateChanged" HorizontalAlignment="Stretch" >
                                    <DatePicker.SelectedDate>
                                        <Binding ElementName="lstSchedules" Path="SelectedItem.Row.END_DATE" Converter="{StaticResource dateConverter}" NotifyOnTargetUpdated="True" NotifyOnSourceUpdated="True" UpdateSourceTrigger ="PropertyChanged" />
                                    </DatePicker.SelectedDate>
                                    <DatePicker.Resources>
                                        <Style TargetType="DatePickerTextBox">
                                            <Setter Property="IsReadOnly" Value="True"/>
                                        </Style>
                                    </DatePicker.Resources>
                                </DatePicker>
                            </DockPanel>
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="0">
                            <Label Content="StartTime:" Name="label71" HorizontalAlignment="Left" />
                            <DockPanel HorizontalAlignment="Stretch" >
                                <Button Content="" DockPanel.Dock="Right" Margin="2" HorizontalAlignment="Right" Name="btnStartTImeReset" VerticalAlignment="Top" Width="1" IsEnabled="false" Visibility="Hidden" />
                                <xctk:DateTimeUpDown Format="Custom" Margin="2" FormatString="hh:mm:ss tt" Name="dtStartTime" TabIndex="17" ValueChanged="dtStartTime_ValueChanged" >
                                    <xctk:DateTimeUpDown.Value>
                                        <Binding ElementName="lstSchedules" Path="SelectedItem.Row.START_TIME" />
                                    </xctk:DateTimeUpDown.Value>
                                </xctk:DateTimeUpDown>
                            </DockPanel>
                       </StackPanel>
                        <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="1">
                            <Label Content="EndTime:" Name="label7" HorizontalAlignment="Left" />
                            <DockPanel HorizontalAlignment="Stretch" >
                                <Button Content="Reset" DockPanel.Dock="Right" Margin="2" HorizontalAlignment="Right" Name="btnEndTImeReset" VerticalAlignment="Top" Width="50" Click="btnEndTImeReset_Click" />
                                <xctk:DateTimeUpDown Format="Custom" Margin="2" FormatString="hh:mm:ss tt" Name="dtEndTime" TabIndex="18" ValueChanged="dtEndTime_ValueChanged" >
                                    <xctk:DateTimeUpDown.Value>
                                        <Binding ElementName="lstSchedules" Path="SelectedItem.Row.END_TIME" />
                                    </xctk:DateTimeUpDown.Value>
                                </xctk:DateTimeUpDown>
                            </DockPanel>
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Grid.Row="2" Grid.Column="0">
                            <Label Content="Schedule Type:" Name="label11" HorizontalAlignment="Left" />
                            <ComboBox Name="cmbScheduleTask" Margin="2" TabIndex="19"  
                                      SelectedValue="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.SCHEDULE_TYPE_ID}" 
                                      ItemsSource="{Binding Path=TaskScheduleTypesTable}" 
                                      DisplayMemberPath="TASK_SCHEDULE_TYPE_DESC" 
                                      SelectedValuePath="TASK_SCHEDULE_TYPE_ID" SelectionChanged="cmbScheduleTask_SelectionChanged" />
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Grid.Row="2" Grid.Column="1">
                            <Label Content="T1(Holiday fall on runday)" Name="label13" />
                            <DockPanel HorizontalAlignment="Stretch" >
                                <Button Content="" DockPanel.Dock="Right" Margin="2" HorizontalAlignment="Right" Name="btnT1Reset" VerticalAlignment="Top" Width="1" IsEnabled="false" Visibility="Hidden" />
                                <xctk:IntegerUpDown Name="iudTPlus" Margin="2" AllowTextInput="False" Maximum="5" Minimum="-5" TabIndex="20" Text="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.T1, UpdateSourceTrigger=PropertyChanged}" />
                            </DockPanel>
                        </StackPanel>
                        <GroupBox Grid.Row="3" Grid.ColumnSpan="2" Header="Daily" x:Name="grpDaily" HorizontalAlignment="Stretch" >
                            <GroupBox.Style>
                                <Style>
                                    <Setter Property="UIElement.IsEnabled" Value="False"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding SelectedIndex, ElementName=lstSchedules}" Value="-1">
                                            <Setter Property="UIElement.IsEnabled" Value="false" />
                                        </DataTrigger>
                                        <DataTrigger Value="true">
                                            <DataTrigger.Binding>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.SCHEDULE_TYPE_ID" Converter="{StaticResource IntegerToBoolConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>1</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </DataTrigger.Binding>
                                            <Setter Property="UIElement.IsEnabled" Value="true" />
                                        </DataTrigger>
                                        <DataTrigger Value="true" Binding="{Binding SelectedItem.Row.DEPENDENCIES, Converter={StaticResource dependencyExistsConverter}, ElementName=lstSchedules}">
                                            <Setter Property="UIElement.IsEnabled" Value="true" />
                                        </DataTrigger>
                                        <DataTrigger Value="false" Binding="{Binding SelectedItem.Row.DEPENDENCIES, Converter={StaticResource dependencyExistsConverter}, ElementName=lstSchedules}">
                                            <Setter Property="UIElement.IsEnabled" Value="false" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </GroupBox.Style>
                            <StackPanel Orientation="Horizontal" >
                                <Label Content="Every" x:Name="label16" VerticalAlignment="Center" />
                                <xctk:IntegerUpDown Maximum="5" Minimum="1" AllowTextInput="False"  x:Name="iudDailyEveryDays" TabIndex="21" Width="100" 
                        			Text="{Binding SelectedItem.Row.DAILY_EVERY_DAYS, ElementName=lstSchedules, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" />
                                <Label Content="day(s)" x:Name="label17" VerticalAlignment="Center" />
                            </StackPanel>
                        </GroupBox>
                        <GroupBox Grid.Row="4" Grid.ColumnSpan="2" Header="Weekly" Name="grpWeekly" >
                            <GroupBox.Style>
                                <Style>
                                    <Setter Property="GroupBox.IsEnabled" Value="False"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ElementName=lstSchedules, Path=SelectedIndex}" Value="-1">
                                            <Setter Property="GroupBox.IsEnabled" Value="false" />
                                        </DataTrigger>
                                        <DataTrigger Value="true">
                                            <DataTrigger.Binding>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.SCHEDULE_TYPE_ID" Converter="{StaticResource IntegerToBoolConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>2</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </DataTrigger.Binding>
                                            <Setter Property="GroupBox.IsEnabled" Value="true" />
                                        </DataTrigger>
                                        <DataTrigger Value="true">
                                            <DataTrigger.Binding>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.DEPENDENCIES" Converter="{StaticResource dependencyExistsConverter}" />
                                            </DataTrigger.Binding>
                                            <Setter Property="GroupBox.IsEnabled" Value="true" />
                                        </DataTrigger>
                                        <DataTrigger Value="false">
                                            <DataTrigger.Binding>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.DEPENDENCIES" Converter="{StaticResource dependencyExistsConverter}" />
                                            </DataTrigger.Binding>
                                            <Setter Property="GroupBox.IsEnabled" Value="false" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </GroupBox.Style>
                            <StackPanel Orientation="Vertical">
                                <DockPanel>
                                    <Label DockPanel.Dock="Left" Content="Every" Name="label14" VerticalAlignment="Center" />
                                    <xctk:IntegerUpDown DockPanel.Dock="Left" Name="iudWeeklyEveryWeek" AllowTextInput="False" Width="50" Maximum="5" Minimum="1" TabIndex="22" 
                                                Text="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.WEEKLY_EVERY_WEEKS, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" />
                                    <Label DockPanel.Dock="Left" Content="week(s) on" Name="label15" VerticalAlignment="Center" />
                                    <WrapPanel VerticalAlignment="Center" HorizontalAlignment="Stretch">
                                        <CheckBox Content="SUN" Padding="1" Margin="1" IsChecked="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.SUN}" Name="chkSUN" TabIndex="23" VerticalAlignment="Center" />
                                        <CheckBox Content="MON" Padding="1" Margin="1" IsChecked="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.MON}" Name="chkMON" TabIndex="24" VerticalAlignment="Center" />
                                        <CheckBox Content="TUE" Padding="1" Margin="1" IsChecked="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.TUE}" Name="chkTUE" TabIndex="25" VerticalAlignment="Center" />
                                        <CheckBox Content="WED" Padding="1" Margin="1" IsChecked="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.WED}" Name="chkWED" TabIndex="26" VerticalAlignment="Center" />
                                        <CheckBox Content="THU" Padding="1" Margin="1" IsChecked="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.THU}" Name="chkTHU" TabIndex="27" VerticalAlignment="Center" />
                                        <CheckBox Content="FRI" Padding="1" Margin="1" IsChecked="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.FRI}" Name="chkFRI" TabIndex="28" VerticalAlignment="Center" />
                                        <CheckBox Content="SAT" Padding="1" Margin="1" IsChecked="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.SAT}" Name="chkSAT" TabIndex="29" VerticalAlignment="Center" />
                                    </WrapPanel>
                                </DockPanel>
                                <StackPanel Orientation="Horizontal">
                                </StackPanel>
                            </StackPanel>
                        </GroupBox>
                        <GroupBox Grid.Row="5" Grid.ColumnSpan="2" Header="Monthly" Name="grpMonthly" >
                            <GroupBox.Style>
                                <Style>
                                    <Setter Property="GroupBox.IsEnabled" Value="False"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding ElementName=lstSchedules, Path=SelectedIndex}" Value="-1">
                                            <Setter Property="GroupBox.IsEnabled" Value="false" />
                                        </DataTrigger>
                                        <DataTrigger Value="true">
                                            <DataTrigger.Binding>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.SCHEDULE_TYPE_ID" Converter="{StaticResource IntegerToBoolConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>3</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </DataTrigger.Binding>
                                            <Setter Property="GroupBox.IsEnabled" Value="true" />
                                        </DataTrigger>
                                        <DataTrigger Value="true">
                                            <DataTrigger.Binding>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.DEPENDENCIES" Converter="{StaticResource dependencyExistsConverter}" />
                                            </DataTrigger.Binding>
                                            <Setter Property="GroupBox.IsEnabled" Value="true" />
                                        </DataTrigger>
                                        <DataTrigger Value="false">
                                            <DataTrigger.Binding>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.DEPENDENCIES" Converter="{StaticResource dependencyExistsConverter}" />
                                            </DataTrigger.Binding>
                                            <Setter Property="GroupBox.IsEnabled" Value="false" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </GroupBox.Style>
                            <StackPanel Orientation="Vertical">
                                <StackPanel Orientation="Horizontal">
                                    <RadioButton Name="rdoDayOfMonth" IsChecked="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.MONTHLY_DAY_OF_MONTH}" TabIndex="30" VerticalAlignment="Center" />
                                    <Label Content="Day" Name="label18" VerticalAlignment="Center" />
                                    <xctk:IntegerUpDown Name="iudMonthlyEveryDayOfMonth" AllowTextInput="False" Minimum="1" TabIndex="31" Width="75" 
                                                Text="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.MONTHLY_EVERY_DAY_OF_MONTH, UpdateSourceTrigger=PropertyChanged}"
                                                IsEnabled="{Binding ElementName=rdoDayOfMonth, Path=IsChecked}" />
                                    <Label Content="of the month(s)" Name="label19" VerticalAlignment="Center" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <RadioButton Name="rdoOption2"
                                         IsChecked="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.MONTHLY_DAY_OF_MONTH, Converter={StaticResource BoolInverterConverter}}" TabIndex="32" VerticalAlignment="Center" />
                                    <Label Content="The" Name="label20" VerticalAlignment="Center" />
                                    <ComboBox Name="cboDaysOfWeek" Margin="2" TabIndex="34" 
                                      ItemsSource="{Binding Path=DayOfWeeks}"          
                                      DisplayMemberPath = "Item2"
                                      SelectedValuePath = "Item1"
                                      SelectedValue="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.MONTHLY_EVERY_WEEKDAY_OF_MONTH}" 
                                      IsEnabled="{Binding ElementName=rdoOption2, Path=IsChecked}" 
                                      Width="75"
                                          />
                                    <ComboBox Name="cboWeekOfMonth" Margin="2" TabIndex="33" 
                                      ItemsSource="{Binding Path=MonthWeeks}" 
                                      DisplayMemberPath = "Item2"
                                      SelectedValuePath = "Item1"
                                      SelectedValue="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.MONTHLY_EVERY_WEEK_OF_MONTH}" 
                                      IsEnabled="{Binding ElementName=rdoOption2, Path=IsChecked}" 
                                      Width="75"
                                          />
                                    <Label Content="of the month(s)" Name="label21" Width="96" VerticalAlignment="Center" />
                                </StackPanel>
                                <GroupBox Header="Select Months">
                                    <GroupBox.Style>
                                        <Style>
                                            <Setter Property="GroupBox.IsEnabled" Value="True"/>
                                        </Style>
                                    </GroupBox.Style>
                                    <WrapPanel Name="wpMonths" 
                                       IsEnabled="{Binding ElementName=rdoOption2, Path=IsChecked}" >
                                        <WrapPanel.Resources>
                                            <Style TargetType="{x:Type CheckBox}">
                                                <Setter Property="Margin" Value="1,0" />
                                            </Style>
                                        </WrapPanel.Resources>
                                        <CheckBox Content="JAN" Margin="2" Name="checkBox1" TabIndex="35" Width="50" VerticalAlignment="Center" >
                                            <CheckBox.IsChecked>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.MONTHLY_SELECTED_MONTHS" Converter="{StaticResource monthSelectedConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>1</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </CheckBox.IsChecked>
                                        </CheckBox>
                                        <CheckBox Content="FEB" Margin="2" x:Name="checkBox2" TabIndex="36" Width="50" >
                                            <CheckBox.IsChecked>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.MONTHLY_SELECTED_MONTHS" Converter="{StaticResource monthSelectedConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>2</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </CheckBox.IsChecked>
                                        </CheckBox>
                                        <CheckBox Content="MAR" Margin="2" Name="checkBox3" TabIndex="37" Width="50" FontStretch="Normal">
                                            <CheckBox.IsChecked>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.MONTHLY_SELECTED_MONTHS" Converter="{StaticResource monthSelectedConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>3</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </CheckBox.IsChecked>
                                        </CheckBox>
                                        <CheckBox Content="APR" Margin="2" Name="checkBox4" TabIndex="38" Width="50" >
                                            <CheckBox.IsChecked>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.MONTHLY_SELECTED_MONTHS" Converter="{StaticResource monthSelectedConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>4</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </CheckBox.IsChecked>
                                        </CheckBox>
                                        <CheckBox Content="MAY" Margin="2" Name="checkBox5" TabIndex="39" Width="50" >
                                            <CheckBox.IsChecked>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.MONTHLY_SELECTED_MONTHS" Converter="{StaticResource monthSelectedConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>5</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </CheckBox.IsChecked>
                                        </CheckBox>
                                        <CheckBox Content="JUN" Margin="2" Name="checkBox6" TabIndex="40" Width="50" >
                                            <CheckBox.IsChecked>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.MONTHLY_SELECTED_MONTHS" Converter="{StaticResource monthSelectedConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>6</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </CheckBox.IsChecked>
                                        </CheckBox>
                                        <CheckBox Content="JUL" Margin="2" Name="checkBox7" TabIndex="41" Width="50" >
                                            <CheckBox.IsChecked>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.MONTHLY_SELECTED_MONTHS" Converter="{StaticResource monthSelectedConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>7</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </CheckBox.IsChecked>
                                        </CheckBox>
                                        <CheckBox Content="AUG" Margin="2" Name="checkBox8" TabIndex="42" Width="50" >
                                            <CheckBox.IsChecked>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.MONTHLY_SELECTED_MONTHS" Converter="{StaticResource monthSelectedConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>8</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </CheckBox.IsChecked>
                                        </CheckBox>
                                        <CheckBox Content="SEP" Margin="2" Name="checkBox9" TabIndex="43" Width="50" >
                                            <CheckBox.IsChecked>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.MONTHLY_SELECTED_MONTHS" Converter="{StaticResource monthSelectedConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>9</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </CheckBox.IsChecked>
                                        </CheckBox>
                                        <CheckBox Content="OCT" Margin="2" Name="checkBox10" TabIndex="44" Width="50" >
                                            <CheckBox.IsChecked>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.MONTHLY_SELECTED_MONTHS" Converter="{StaticResource monthSelectedConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>10</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </CheckBox.IsChecked>
                                        </CheckBox>
                                        <CheckBox Content="NOV" Margin="2" Name="checkBox11" TabIndex="45" Width="50" VerticalAlignment="Center" >
                                            <CheckBox.IsChecked>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.MONTHLY_SELECTED_MONTHS" Converter="{StaticResource monthSelectedConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>11</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </CheckBox.IsChecked>
                                        </CheckBox>
                                        <CheckBox Content="DEC" Margin="2" Name="checkBox12" TabIndex="46" Width="50" >
                                            <CheckBox.IsChecked>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.MONTHLY_SELECTED_MONTHS" Converter="{StaticResource monthSelectedConverter}">
                                                    <Binding.ConverterParameter>
                                                        <sys:Int32>12</sys:Int32>
                                                    </Binding.ConverterParameter>
                                                </Binding>
                                            </CheckBox.IsChecked>
                                        </CheckBox>
                                    </WrapPanel>
                                </GroupBox>
                            </StackPanel>
                        </GroupBox>
                        <GroupBox Grid.Row="6" Grid.Column="0" Name="grpRepeat" >
                            <GroupBox.Header>
                                <CheckBox Content="Repeat" IsChecked="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.REPEAT_ENABLED}" Name="chkRepeat" TabIndex="47" />
                            </GroupBox.Header>
                            <GroupBox.Style>
                                <Style>
                                    <Style.Triggers>
                                        <DataTrigger Value="true">
                                            <DataTrigger.Binding>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.DEPENDENCIES" Converter="{StaticResource dependencyExistsConverter}" />
                                            </DataTrigger.Binding>
                                            <Setter Property="GroupBox.IsEnabled" Value="true" />
                                        </DataTrigger>
                                        <DataTrigger Value="false">
                                            <DataTrigger.Binding>
                                                <Binding ElementName="lstSchedules" Path="SelectedItem.Row.DEPENDENCIES" Converter="{StaticResource dependencyExistsConverter}" />
                                            </DataTrigger.Binding>
                                            <Setter Property="GroupBox.IsEnabled" Value="false" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </GroupBox.Style>
                            <StackPanel Orientation="Horizontal" Name="cvsRepeat" IsEnabled="{Binding ElementName=chkRepeat, Path=IsChecked}">
                                <Label Content="Every" Name="label22" VerticalContentAlignment="Top" />
                                <xctk:IntegerUpDown Name="iudRepeatInterval" AllowTextInput="False" Minimum="1" Margin="2" TabIndex="48" Text="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.REPEAT_INTERVAL, UpdateSourceTrigger=PropertyChanged}" Width="100" DefaultValue="1" />
                                <ComboBox DisplayMemberPath="Item2" Margin="2" ItemsSource="{Binding Path=RepeatIntervalTypes}" Name="cmbRepeatIntervalType" SelectedValue="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.REPEAT_INTERVAL_TYPE}" SelectedValuePath="Item1" TabIndex="49" Width="100" />
                            </StackPanel>
                        </GroupBox>
                        <GroupBox Grid.Row="6" Grid.Column="1" Name="grpHolidayCal" Header="Holiday Calendar" >
                            <GroupBox.Style>
                                <Style></Style>
                            </GroupBox.Style>
                            <ComboBox Name="cmbHolidayCal" Margin="3" 
                                    SelectedValue="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.HOLIDAY_CAL_ID}" TabIndex="13" 
                                    ItemsSource="{Binding Path=TaskHolidayCalTable}" 
                                    DisplayMemberPath="CAL_NAME" 
                                    SelectedValuePath="CAL_ID" SelectionChanged="cmbHolidayCal_SelectionChanged" />
                        </GroupBox>
                        <DockPanel Grid.Row="7" Grid.ColumnSpan="2" >
                            <Button Margin="2" Name="btnDependencies" 
                            Content="Dependencies" TabIndex="10" Width="100" Height="25" Click="txtDependencies_Click" HorizontalAlignment="Right" DockPanel.Dock="Right" VerticalAlignment="Center">
                                <Button.Style>
                                    <Style>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding ElementName=lstSchedules, Path=SelectedIndex}" Value="-1">
                                                <Setter Property="Button.IsEnabled" Value="false" />
                                            </DataTrigger>
                                            <DataTrigger Value="true">
                                                <DataTrigger.Binding>
                                                    <Binding ElementName="lstSchedules" Path="SelectedItem.Row.SCHEDULE_TYPE_ID" Converter="{StaticResource IntegerToBoolConverter}">
                                                        <Binding.ConverterParameter>
                                                            <sys:Int32>1</sys:Int32>
                                                        </Binding.ConverterParameter>
                                                    </Binding>
                                                </DataTrigger.Binding>
                                                <Setter Property="Button.IsEnabled" Value="true" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Button.Style>
                                <Button.Background>
                                    <Binding ElementName="lstSchedules" Path="SelectedItem.Row.DEPENDENCIES" Converter="{StaticResource dependencyBackgroudColorConverter}" >
                                        <Binding.TargetNullValue>
                                            <SolidColorBrush>
                                                <SolidColorBrush.Color>LightGray</SolidColorBrush.Color>
                                            </SolidColorBrush>
                                        </Binding.TargetNullValue>
                                        <Binding.FallbackValue>
                                            <SolidColorBrush>
                                                <SolidColorBrush.Color>LightGray</SolidColorBrush.Color>
                                            </SolidColorBrush>
                                        </Binding.FallbackValue>
                                    </Binding>
                                </Button.Background>
                            </Button>

                            <GroupBox Name="grpRepeat1" Margin="2" DockPanel.Dock="Left" Header="Comments">
                                <GroupBox.Style>
                                    <Style></Style>
                                </GroupBox.Style>
                                <TextBox Name="txtScheduleDesc" Margin="2" 
                                     Text="{Binding ElementName=lstSchedules, Path=SelectedItem.Row.SCHEDULE_DESC, UpdateSourceTrigger=PropertyChanged}" TabIndex="14" 
                                     AcceptsTab="True" AcceptsReturn="True" VerticalScrollBarVisibility="Hidden" TextWrapping="Wrap" 
                                     MouseDoubleClick="txtScheduleDesc_MouseDoubleClick" ToolTip="Double click to edit the content..." 
                                 />
                            </GroupBox>
                        </DockPanel>
                    </Grid>
                </GroupBox>
            </Grid>
        </StackPanel>
    </Grid>
</local:ChoBaseWindowEx>


<!--SelectedItem="{Binding Path=SelectedYearMonth}"--> 
    